package com.yutian.endecryption.frame;

import com.yutian.endecryption.VERSION;
import com.yutian.endecryption.aes.component.JTabbedAES;
import com.yutian.endecryption.config.Config;
import com.yutian.endecryption.mock.component.JTabbedMock;

import javax.swing.*;
import java.awt.*;

import static com.yutian.endecryption.config.Config.TOOL_NAME;

/**
 * 主程序入口
 * @author zhang peng yang ming
 * @create 2017-07-25 10:14
 */
public class MainFrame {
    private JFrame main = null;

    public MainFrame() {
        //界面风格和当前操作系统的界面保持一致
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            Font font = new Font("微软雅黑",   Font.PLAIN,   14);
            UIManager.put("Button.font", font);
            UIManager.put("Menu.font", font);
            UIManager.put("MenuItem.font", font);
            UIManager.put("Label.font", font);
            UIManager.put("Label.Color", Color.red);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (UnsupportedLookAndFeelException e) {
            e.printStackTrace();
        }

        main = new JFrame(TOOL_NAME + "  (" + VERSION.getVersionNumber() + ")");
        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();

        main.setResizable(false);  //不允许最大化
        main.setSize((int)(dimension.width * Config.SCALE), (int)(dimension.height * (Config.SCALE + 0.05)));
        main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        main.setLocation(((int)(dimension.width * (1 - Config.SCALE))) / 2, ((int)(dimension.height * (1 - Config.SCALE))) / 2);


        JTabbedPane tp = new JTabbedPane();
        tp.add("AES 加解密 ", new JTabbedAES());
        tp.add("模拟考试助手", new JTabbedMock());
        main.add(tp);
        main.setVisible(true);
    }
}
